﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Client.View.CommonView
{
    /// <summary>
    /// OrgTree.xaml 的交互逻辑
    /// </summary>
    public partial class OrgTreeNoBtn : UserControl
    {
        public OrgTreeNoBtn()
        {
            InitializeComponent();
        }


        public void ResetSelectedStatus()
        {
            foreach (var item in OrgTree.Items)
            {
                var tvi = (TreeViewItem)OrgTree.ItemContainerGenerator.ContainerFromItem(item);
                if (tvi.IsSelected)
                {
                    tvi.IsSelected = false;
                }
                RecuResetSelectedStatus(tvi);
            }
        }

        private void RecuResetSelectedStatus(TreeViewItem tvi)
        {
            if (tvi.Items.Count > 0)
            {
                foreach (var item in tvi.Items)
                {
                    var child = (TreeViewItem)tvi.ItemContainerGenerator.ContainerFromItem(item);
                    if (child.IsSelected)
                    {
                        child.IsSelected = false;
                    }
                    RecuResetSelectedStatus(child);
                }
            }
        }



    }
}
